# coding: utf-8

"""
@version: python3.6
@author: 噢啦嘿嘿
@contact: jian.zhou@360che.com
@software: PyCharm
@file: android.py
@time: 2021/1/20 15:52
"""


import os
from lib.loggers import log
from lib import uiautomator2 as u2



def device_android(d_id = 1) -> u2.Device:
    log.info(d_id)
    if isinstance(d_id, int):
        return u2.connect()
    else:
        return u2.connect(d_id)


def devices():
    a = os.popen('adb devices').readlines()
    if len(a) >= 2:
        dl = [i.split('\t')[0] for i in a if '\t' in i]
    else:
        dl = 'adb 异常，未获取到设备'
    return dl

